package org.afei.ioc.data;

import java.util.HashMap;
import java.util.Map;

/**
 * 默认服务提供者实例的缓存区
 *
 * @author afei
 * @date 17-5-25.
 */
public class DefaultBeanCacheContext implements
        DataContext {
    private Map<String, Object> beanCacheMap;

    @Override
    public void initData(Map<String, Object> map) {
        beanCacheMap = new HashMap<>();
    }

    @Override
    public void set(String name, Object obj) {

        beanCacheMap.put(name, obj);
    }

    @Override
    public Object get(String name) {
        return beanCacheMap.get(name);
    }

    @Override
    public <T> T get(String name, Class<T> clazz) {
        return (T) beanCacheMap.get(name);
    }

    @Override
    public Map<String, Object> getAll() {
        return beanCacheMap;
    }

}
